﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Sonic.Framework.Extensions
{
    public static class FileInfoExtensions
    {
        /// <summary>
        /// Generates a new FileInfo with the postfix string inserted at the end of the file name, but before the extension
        /// </summary>
        /// <param name="fileInfo"></param>
        /// <param name="postfix"></param>
        /// <returns></returns>
        public static FileInfo GetPostfixFileInfo(this FileInfo fileInfo, string postfix)
        {
            string directory = fileInfo.DirectoryName + @"\";
            string extension = fileInfo.Extension;
            string name = fileInfo.Name.Substring(0, fileInfo.Name.Length - extension.Length);

            FileInfo postfixedFileInfo = new FileInfo(directory + name + postfix + extension);

            return postfixedFileInfo;
        }

    }
}
